﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using snat.algorithms;
using System.ComponentModel;

namespace gui {

    /// <summary>
    /// GUI Notifiable AlgorithmItem Class
    /// Algorithm Item holds an IAlgorithm, a selected boolean
    /// and an enabled boolean property
    /// </summary>
    public class AlgorithmItem : INotifyPropertyChanged {

        private bool selected;
        public bool Selected {
            get { return selected; }
            set {
                if (selected == value) return;
                selected = value;
                if (null != this.PropertyChanged) {
                    PropertyChanged(this, new PropertyChangedEventArgs("Selected"));
                }
            }
        }

        private bool enabled;
        public bool Enabled {
            get { return enabled; }
            set {
                if (enabled == value) return;
                enabled = value;
                if (null != this.PropertyChanged) {
                    PropertyChanged(this, new PropertyChangedEventArgs("Enabled"));
                }
            }
        }

        public string Name { get; set; }

        public IAlgorithm Algorithm { get; set; }

        public AlgorithmItem(IAlgorithm a, String name) {
            Algorithm = a;
            Selected = false;
            Enabled = false;
            this.Name = name;
        }

        public AlgorithmItem(IAlgorithm a, String name, bool defaultSelection) {
            Algorithm = a;
            Selected = defaultSelection;
            Enabled = false;
            this.Name = name;
        }

        public event PropertyChangedEventHandler PropertyChanged;
    }
}
